package pl.elka.simulator.gui.swt.menu;

import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Shell;

import pl.elka.simulator.core.Simulator;
import pl.elka.simulator.gui.swt.IReloadable;
import pl.elka.simulator.mediator.SimulationFasade;

public class NewSelection extends SelectionAdapter {

	private Shell shell;
	public NewSelection(Shell shell){
		this.shell = shell;
	}
	
	@Override
	public void widgetSelected(SelectionEvent e) {		
		SimulationFasade.getInstance().setSimulator(new Simulator());
		
		shell.redraw();
		for(Control c :shell.getChildren()){
			if(c instanceof IReloadable){
				((IReloadable)c).reloadContent();
			}
		} 
	}
}
